 var linkurl = "http://"+window.location.host+"/";
 var indexs = ["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩"];
 var page =1;
 var t = n = 0, count;
 var index = 0;
 var auto_timer;
 $(document).ready(function () {
     $.ajax({
         type : "get",
         url : linkurl + "isLoged",
         data: {},
         dataType: 'json',
         success:function (Result) {
             var result = Result.result;
             if(result==1){
                 $(".pcc_gerenbnt").removeClass("hide");
                 $("#to-login").addClass("hide");
                 $("#to-reg").addClass("hide");
             }
         }
     });
     $.ajax({
         type: 'get',
         url : linkurl + "getAdList",
         data: {pid:1},
         dataType: 'json',
         success:function (Result) {
             var data = Result.data;
             var html="";
             $("#banner_list").html("");
             $.each(data,function (index,item) {
                 html =html+"<a class='item2 rel' target='_blank' href='//"+item.linkUrl+"'>" +
                     "<img class='banner-img' src='"+linkurl+"images/ad/"+item.img+"'>" +
                     "<div class='title-mask abs'></div>" +
                     "<div class='title abs fff' style='font-size:26px;'>"+item.adTitle+"</div>" +
                     "</a>";
             })
             $("#banner_list").html(html);
         }
     });
     count = 3;
     for(var i = 0;i<count;i++){$("#banner").append("<li></li>");}
     $("#banner_list a:not(:first-child)").hide();
     $("#banner_info").html($("#banner_list a:first-child").find("img").attr('alt'));
     $("#banner_info").click(function () {
         window.open($("#banner_list a:first-child").attr('href'), "_blank")
     });
     $("#banner li").on('click', function () {
         var i = $(this).index();//获取Li元素内的值，即1，2，3，4
         n = i;
         if (i >= count) return;
         $("#banner_info").html($("#banner_list a").eq(i).find("img").attr('alt'));
         $("#banner_info").unbind().click(function () {
             window.open($("#banner_list a").eq(i).attr('href'), "_blank")
         });
         $("#banner_list a").filter(":visible").hide().parent().children().eq(i).show();
         document.getElementById("banner").style.background = "";
         $(this).toggleClass("on");
         $(this).siblings().removeAttr("class");
     });
     t = setInterval("showAuto()", 3000);
     $("#banner").hover(function () {
         clearInterval(t)
     }, function () {
         t = setInterval("showAuto()", 3000);
     });
 });
 $(function () {
	//右侧导航点击回到头部
	 $("#sidebar-c").click(function(){
	                $('body,html').animate({scrollTop:0},1000);
	                return false;
	            });

	$.ajax({
        type: 'get',
        url : linkurl + "getXunrenClassifyList",
        data: {},
        dataType: 'json',
        success: function (Result) {
            var  data = Result.data;
            $(".pcc-items1").html("");
            $.each(data, function (index,item) {
                $(".pcc-items1").append("<a href='d-"+item.id+"/'>"+item.className+"</a>")
            })
        }
    });
    $.ajax({
        type: 'get',
        url : linkurl + "getCommendList",
        data: {},
        dataType: 'json',
        success: function (Result) {
            var  data = Result.data;
            $(".pcc-item-in").html("");
            $.each(data, function (index,item) {
                $(".pcc-item-in").append("<li>" +
                    "<a href='"+linkurl+item.url+"/"+item.linkUrl+"'>" +
                    "<span class='text'>"+item.title+"</span>" +
                    "<span class='muted'>" +
                    "<time><i class='fa fa-clock-o'></i>"+dateFormatUtil(item.createTime*1000)+"</time>" +
                    "</span>" +
                    "<span class='muted'>阅读("+item.hits+")" +
                    "</span>" +
                    "</a>" +
                    "</li>")
            })
        }
    });
    $.ajax({
        type: 'get',
        url : linkurl + "getzuixinXunrenList",
        data: {page : page,pagesize : 4},
        dataType: 'json',
        success:function (Result) {
            var  data = Result.data;
            if(page == 1){
                $("#pcc-xunren").html("");
            }
            $.each(data, function (index,item) {
                $("#pcc-xunren").append("<a class='article-list cursor' target='_blank' href='"+item.url+"/"+item.linkUrl+"'>" +
                    "<div class='article rel bb'>" +
                    "<img class='cover abs' src='upload/image/"+item.img+"'>" +
                    "<div class='title hover c3333'>["+item.provinceName+"] "+item.title+" </div><div class='author c333'>寻找人："+item.contact+" <em class='bbb'>"+dateFormatUtil(item.createTime*1000)+"</em></div>" +
                    "<div class='summary'>" + item.content + "</div>" +
                    "</div>" +
                    "</a>");
            })
        }
    })
    $.ajax({
        type : "get",
        url : linkurl + "getindexDiquListByType",
        data: {types : 1,pid : 0},
        dataType: 'json',
        success : function (Result) {
            var data = Result.data;
            $("#pcc-area-province").html("");
            $.each(data, function (index,item) {
                $("#pcc-area-province").append("<a href='"+linkurl+"a-"+item.url+"/'>"+item.diquName+"</a>")
            })
        }
    });
    $.ajax({
        type : "get",
        url : linkurl + "getzuixinXunrenList",
        data: {pagesize:10},
        dataType: 'json',
        success:function (Result) {
            var data = Result.data;
            $("#live_radio_list").html("<div class='live_radio_listtitle'><h3>本站最新发布</h3></div>");
            $.each(data, function (index,item) {
                if(index<=2){
                 $("#live_radio_list").append("<a href='"+item.url+"/"+item.linkUrl+"' class='live_xunren_list'><span class='pcc-colorff8420 pcc_padding10'>"+indexs[index]+"</span>["+item.provinceName+"] "+item.title+" </a>");
                }else{
                 $("#live_radio_list").append("<a href='"+item.url+"/"+item.linkUrl+"' class='live_xunren_list'><span class='pcc-colore0dbdb pcc_padding10'>"+indexs[index]+"</span>["+item.provinceName+"] "+item.title+" </a>");
                }
            })
        }
    });
    $.ajax({
        type : "get",
        url : linkurl + "getFriendsList",
        data: {},
        dataType: 'json',
        success : function (Result) {
            var data = Result.data;
            var url ="";
            $("#pcc-youqing").html("");
            $("#pcc-youqing").append("友情链接：");
            $.each(data, function (index,item) {
                $("#pcc-youqing").append("<a href='//"+item.url+"'>"+item.title+"</a>")
            })
        }
    });
    $(".search_button").click(function () {
        $.ajax({
            type : "get",
            url : linkurl + "getzuixinXunrenList",
            data: {search:$("#search_key").val(),page : page,pagesize:4},
            dataType: 'json',
            success:function (Result) {
                var data = Result.data;
                $("#pcc-xunren").html("<div class='live_radio_listtitle'><h3>本站最新发布</h3></div>");
                $.each(data, function (index,item) {
                    var province = "";
                    $.ajax({
                        type: 'get',
                        url : linkurl + "getDiqu",
                        data: {id : item.province},
                        async:false,
                        dataType: 'json',
                        success:function (Result) {
                            var data = Result.data;
                            province = data.diquName;
                        }
                    })
                    $("#pcc-xunren").append("<a class='article-list cursor' target='_blank' href='"+item.url+"/"+item.linkUrl+"'>" +
                        "<div class='article rel bb'>" +
                        "<img class='cover abs' src='../upload/image/"+item.img+"'>" +
                        "<div class='title hover c3333'>["+province+"] "+item.title+" </div><div class='author c333'>寻找人："+item.contact+" <em class='bbb'>"+dateFormatUtil(item.createTime)+"</em></div>" +
                        "<div class='summary'>" + item.content + "</div>" +
                        "</div>" +
                        "</a>");
                })
            }
        })
    });
    $(".search_button3").click(function () {
        var search = $("#search_key").val();
        if(search!=""){
            window.location.href = "sousuojieguo.html?search=" + search;
        }
    });
    $("#pcc-logout").click(function () {
        $.ajax({
            type : "post",
            url : linkurl + "logout",
            data: {},
            dataType: 'json',
            success:function () {
                $(".pcc_gerenbnt").addClass("hide");
                $("#to-login").removeClass("hide");
                $("#to-reg").removeClass("hide");
            }
        })
    })
    
       
    })
 function dateFormatUtil(longTypeDate){
        var dateTypeDate = "";
        var date = new Date();
        date.setTime(longTypeDate);
        dateTypeDate += date.getFullYear();   
        dateTypeDate += "-" + getMonth(date); 
        dateTypeDate += "-" + getDay(date);    
        return dateTypeDate;
    }
 function getMonth(date){
        var month = "";
        month = date.getMonth() + 1;  
        if(month<10){
            month = "0" + month;
        }
        return month;
    }
 function getDay(date){
        var day = "";
        day = date.getDate();
        if(day<10){
            day = "0" + day;
        }
        return day;
    }
 function showAuto() {
     n = n >= (count - 1) ? 0 : ++n;
     //console.log("n="+n)
     $("#banner li").eq(n).trigger('click');
 }
 function autoChangeItem() {
     index++;
     var length = $("#live_radio_list").find('.broadcast').length;
     var i = index % length;
     $("#live_radio_list").find('.broadcast').removeClass('hide').addClass('hide');
     $("#live_radio_list").find('.broadcast').eq(i).removeClass('hide');
 }